1
'****************************** Module Header ******************************\
2 ' Module Name: LocalResources.aspx.vb
3 ' Project: VBASPNETLocalization
4 ' Copyright (c) Microsoft Corporation
6 ' The project illustrates how to build a multi-lingual website with ASP.NET
7 ' Localization. ASP.NET enables pages obtain content and other data based
8 ' on the preferred language setting of the browser or based on the user's
9 ' explicit choice of language. If controls are configured to get property
10 ' values from resources, at run time, the resource expressions are replaced
11 ' by resources from the appropriate resource file.
13 ' This page tells how to use Local Resources files to make controls simply
14 ' localized into other languages following the selection from DropDownList.
15 ' According to the choice, the language of the controls in the page can be
16 ' changed. Besides the text's language, we can also change other properties,
17 ' like the color of the Label in the demo. However, all these changes are
18 ' based on the Local Resources file whose name is as the same as the page's
19 ' That means all these changes only works in this single page and when we
20 ' redirect to another page, they will be lost. To handle this issue, please
21 ' refer to GlobalResources.aspx's description.
23 ' This source is subject to the Microsoft Public License.
24 ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
25 ' All other rights reserved.
28 ' * 7/27/2009 6:00 PM Bravo Yang Created
29 '***************************************************************************/
31 #Region
"Imports Directory"
32 Imports System
.Threading
33 Imports System
.Globalization
37 Partial
Public Class LocalResources
38 Inherits System
.Web
.UI
.Page
40 Protected Overrides
Sub InitializeCulture()
42 ' Get the user's selection from DropDownList by Request.Form().
43 ' The reason why here we don't use ddlLanguage.SelectedValue is that
44 ' all the page controls, including ddlLanguage is unavailable now.
45 Dim strLanguageInfo
As String = Request
.Form("ddlLanguage")
47 If Not strLanguageInfo Is
Nothing Then
48 ' Set the CurrentUICulture and CurrentCulture to strLanguageInfo.
49 Thread
.CurrentThread
.CurrentUICulture
= New CultureInfo(strLanguageInfo
)
50 Thread
.CurrentThread
.CurrentCulture
= CultureInfo
.CreateSpecificCulture(strLanguageInfo
)